<?php
header('Content-type:text/html;charset=UTF8');

@$pageNum = $_REQUEST['pageNum'];

if(empty($pageNum)||$pageNum < 1 ||!is_numeric($pageNum)){
	$pageNum = 1;
}
$pageSize = 5;

$offset = ($pageNum-1)*$pageSize;

include 'db/li.php';

@$pageCount = dbSelect('select count(1) as c from goods');

$num = ceil($pageCount['c']/$pageSize);

@$goods = dbSelectAll("select goods.id as gId,type.id as tId,imgUrl,goods.name as gName,type.name as tName,price,status,typeId from goods join type on goods.typeId=type.id order by goods.id asc limit $offset,$pageSize");

if(empty($goods)){
	echo json_encode(array('status'=>false,'info'=>'获取数据失败'));
	die;
}

echo json_encode(array('status'=>true,'goods'=>$goods,'num'=>$num));